package com.jwds.digital.bios.business.api.controller.belt;

import com.jwds.digital.bios.business.service.service.belt.IBeltRouteTaskBeltDetailService;
import com.jwds.digital.bios.business.core.infrastructure.dto.belt.BeltRouteTaskBeltDetailReqDTO;
import com.jwds.digital.bios.business.core.infrastructure.vo.belt.BeltRouteTaskBeltDetailRespVO;
import com.jwds.tdc.framework.application.lib.BaseResponse;
import com.jwds.tdc.framework.application.lib.page.PageRequest;
import com.jwds.tdc.framework.application.lib.page.PageResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;

/**
 * 路线作业实绩皮带详情表 前端控制器
 *
 * @author 林柏云
 * @date 2024-12-05
 */
@Slf4j
@Api(tags = "路线作业实绩皮带详情表--接口")
@RestController
@RequestMapping("/belt/route/task/belt/detail")
public class BeltRouteTaskBeltDetailController {

  @Resource
  private IBeltRouteTaskBeltDetailService service;

  @GetMapping("/{id}")
  @ApiOperation(value = "根据id查询")
  public BaseResponse<BeltRouteTaskBeltDetailRespVO> queryById(@PathVariable("id") Long id) {
    BeltRouteTaskBeltDetailRespVO respVo = service.queryById(id);
    return BaseResponse.success(respVo);
  }

  @PostMapping("/list")
  @ApiOperation(value = "分页查询")
  public BaseResponse<PageResponse<BeltRouteTaskBeltDetailRespVO>> page(@Valid @RequestBody PageRequest<BeltRouteTaskBeltDetailReqDTO> pageRequest) {
    PageResponse<BeltRouteTaskBeltDetailRespVO> respVoPage = service.page(pageRequest);
    return BaseResponse.success(respVoPage);
  }

  @PostMapping("/all")
  @ApiOperation(value = "列表查询")
  public BaseResponse<List<BeltRouteTaskBeltDetailRespVO>> list(@Valid @RequestBody BeltRouteTaskBeltDetailReqDTO reqDto) {
    List<BeltRouteTaskBeltDetailRespVO> respVoList = service.list(reqDto);
    return BaseResponse.success(respVoList);
  }

  @PostMapping("/")
  @ApiOperation(value = "新增")
  public BaseResponse<?> add(@Validated @RequestBody BeltRouteTaskBeltDetailReqDTO reqDto) {
    service.add(reqDto);
    return BaseResponse.success();
  }

  @PostMapping("/batch")
  @ApiOperation(value = "批量新增")
  public BaseResponse<?> batchAdd(@Validated @RequestBody List<BeltRouteTaskBeltDetailReqDTO> reqDtoList) {
    service.batchAdd(reqDtoList);
    return BaseResponse.success();
  }

  @PutMapping("/")
  @ApiOperation(value = "更新对象")
  public BaseResponse<?> update(@Validated @RequestBody BeltRouteTaskBeltDetailReqDTO reqDto) {
    service.update(reqDto);
    return BaseResponse.success();
  }

  @DeleteMapping("/{id}")
  @ApiOperation(value = "删除对象")
  public BaseResponse<?> delete(@PathVariable("id") Long id) {
    service.delete(id);
    return BaseResponse.success();
  }

  @DeleteMapping("/batch")
  @ApiOperation(value = "批量删除对象")
  public BaseResponse<?> batchDelete(@RequestBody List<Long> ids) {
    service.batchDelete(ids);
    return BaseResponse.success();
  }

  @GetMapping("/transportRouteDetails/{routeId}")
  @ApiOperation(value = "运输线路详情")
  public BaseResponse<List<BeltRouteTaskBeltDetailRespVO>>getTransportRouteDetails(@PathVariable("routeId")Integer routeId){
    return BaseResponse.success(service.getTransportRouteDetails(routeId));
  }

}
